<template>
    <div class="header_con">
        <div class="header">
            <div class="welcome fl">欢迎 {{ name }} 来到美多商城!</div>
            <div class="fr">
                <div v-if="name" class="login_btn fl">
                    欢迎您：<em>{{ name }}</em>
                    <span>|</span>
                    <a href="javascript:;" @click="logout">退出</a>
                </div>
                <div v-else class="login_btn fl">
                    <a href="/login">登录</a>
                    <span>|</span>
                    <a href="/register">注册</a>
                </div>
                <div class="user_link fl">
                    <span>|</span>
                    <a href="/my_center">用户中心</a>
                    <span>|</span>
                    <a href="/cart">我的购物车</a>
                    <span>|</span>
                    <a href="/user_order">我的订单</a>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "BaseHeader",
        data() {
            return {
               name: sessionStorage.getItem('name')
            }
        },
        methods: {
           logout(){
              sessionStorage.clear();
              this.$router.go(0);
           }
        },
        computed: {},
        filters: {},
        watch: {},
    }
</script>

<style scoped>

</style>
